import re
import sys

promed = sys.argv[1]
daniel = sys.argv[2]
dic_pro = eval(open(promed).read())
dic_dan = eval(open(daniel).read())
cpt = 0
dic_res = {'daniel':{'pays':[],'langues':[]},
           'promed':{'pays':[],'langues':[]}}
cpt2=0
for i in dic_pro:
  if i in dic_dan:
    pays = i[1]
    d_pro,l_pro = dic_pro[i]
    d_pro = int(re.sub('-','',d_pro))
    d_dan,l_dan = dic_dan[i]
    d_dan = int(re.sub('-','',d_dan))
    diff = d_pro-d_dan
    if diff<0:
      dic_res['promed']['langues'].append((l_pro,l_dan))
      dic_res['promed']['pays'].append(pays)
    else:
      cpt2+=1
      dic_res['daniel']['langues'].append((l_pro,l_dan))
      dic_res['daniel']['pays'].append(pays)
    cpt+=1
print cpt2,'en avance sur',cpt
for syst,res in dic_res.iteritems():
  print syst
  print res
  print '-'*8
